package com.xxs.controller.front;

import com.jfinal.aop.Before;
import com.xxs.interceptor.FrontInterceptor;
import com.xxs.utils.xml.XmlDom4jUtils;

@Before(FrontInterceptor.class)
public class NodeController extends BaseFrontController {
	public void index(){
		String nodeId = getPara(0);
		String siteCode = getCurrentSiteCode();
//    	String path = getRequest().getServletPath();
//    	String base = path+"db/"+siteCode+"/front/_files";
    	String base = "/db/"+siteCode+"/front/_files";
    	setAttr("_files", base);
    	setAttr("list", XmlDom4jUtils.getElementsByAttrAndValue(getXmlPath(getCurrentSiteCode(), "info"), "info", "nodeId", nodeId));
    	String modelNodeId = XmlDom4jUtils.getParaValueByAttrAndValue(getXmlPath(getCurrentSiteCode(), "node"), "node", "id", nodeId, "modelNodeId");
    	String template = XmlDom4jUtils.getParaValueByAttrAndValue(getXmlPath(getCurrentSiteCode(), "model"), "node", "id", modelNodeId, "template");
//    	Engine engine = new Engine();
//    	String webPath = PathKit.getWebRootPath();
//    	engine.setBaseTemplatePath(webPath);
//    	Template template = engine.getTemplate("db/"+siteCode+"/front/index.html");
//    	String res = template.renderToString(JMap.create("_files","xxxxxx"));
//    	System.out.println(res);
//    	engine = Engine.use("index11111");
    	render("/db/"+siteCode+"/front"+template);
    }
}
